<%--
  Created by IntelliJ IDEA.
  User: 22531
  Date: 2021/6/24
  Time: 17:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/easyui/themes/icon.css">
    <script type="text/javascript" src="/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/js/jquery.edatagrid.js"></script>
    <script src="/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/js/datagrid-export.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#getTeaSC').edatagrid({
                url: '/tea/getTeaSC',
                saveUrl: '',
                updateUrl: '/tea/teaUpGrade',
                destroyUrl: '',
                title: '学生选课情况',
                columns: [[
                    {field: 'id', title: 'ID', align: 'center'},
                    {field: 'course_name', title: '课程名称', align: 'center'},
                    {field: 'course_id', title: '课程id', align: 'center'},
                    {field: 'stu_id', title: '学生id', align: 'center'},
                    {field: 'grade',title: "分数",align: 'center',editor:{type:'numberbox',options:{required:true}},
                        formatter: function(value,row,index){
                            if(row.grade==0){
                                return '暂无分数';
                            }else {
                                return value;
                            }
                    }
                    }

                ]],
                rownumbers: true,
                pagination: true,
                idField:'id',
                pageSize: 10,
                pageList: [10, 20, 30, 40, 50],
                singleSelect: true,
                toolbar: '#toolbar',
                queryParams: {
                    course_id: $('#c').val(),
                },
                onSuccess:function (index,row){
                    if(row.msg){
                        $.messager.alert('操作结果','操作成功!','info');
                        $('#getTeaSC').edatagrid('reload');
                    }
                    else {
                        $.messager.alert('操作结果','操作失败!'+row.error,'warning');
                        $('#getTeaSC').edatagrid('reload');
                    }
                },
                onError:function (index,row){
                    $.messager.alert('操作结果','服务器错误!','warning');
                    $('#getTeaSC').edatagrid('reload');
                },
                onDestroy:function (index,row){
                    if(row.msg){
                        $.messager.alert('操作结果','操作成功!','info');
                        $('#getTeaSC').edatagrid('reload');
                    }
                    else {
                        $.messager.alert('操作结果','操作失败!'+row.error,'warning');
                        $('#getTeaSC').edatagrid('reload');
                    }
                },
            });
        })
    </script>
</head>
<body>
<div class="easyui-panel" data-options="fit:true,border:false">
    <table id="getTeaSC"></table>
</div>

<div id="toolbar">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-reload" plain="true" onclick="$('#getTeaSC').datagrid('reload')">刷新</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" plain="true">课程：</a>
    <input id="c" class="easyui-combobox" data-options="
                    url:'/tea/teaGetCourse?id=${sessionScope.tea.id}',
                    method:'get',
                    valueField:'id',
                    textField:'name',
                    panelHeight:'auto',

                    labelPosition: 'top',
                    required:true,
                    editable:false,
                    value:1,
                    ">
    <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="$('#getTeaSC').edatagrid('saveRow')">保存</a>
    <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" onclick="$('#getTeaSC').datagrid('toExcel','dg.xls')">ExportToExcel</a>
    <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-undo'" onclick="$('#getTeaSC').edatagrid('cancelRow')">取消</a>
</div>
<script type="text/javascript">

    $('#c').combobox({
        onChange: function(newValue,oldValue){
            $('#getTeaSC').datagrid('load',{
                course_id: $('#c').val(),
                }
            );
        }
    });

</script>
</body>
</html>
